home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / EXT / A-E / AutoCruise.cpt / AutoCruise ƒ / AutoCruise (Source) / Cruise.c next >
C/C++ Source or Header  |  1989-10-07  |  4KB  |  138 lines

  1. /* Cruise.c */
  2.  
  3. /*
  4.   Project Info ->    Code Resource, creator '????', type 'rsrc'
  5.                     Type: 'COOL'
  6.                     Custom Header option on   ( VERY IMPORTANT! )
  7.                     System Heap bit set
  8.                     Locked bit set
  9.                     
  10.                     Compile into code resource called 'Init.π.rsrc' to be 
  11.                     incorporated into the init half of the program.
  12. */
  13.  
  14. #include "Cruise.h"
  15.  
  16. main()
  17.     {
  18.     asm
  19.         {
  20.     MyBlockPtr:
  21.         dc.l    0
  22.         
  23.     Entry:
  24.         lea        @MyBlockPtr,a0
  25.         move.l    (a0),a0                /* Get Globals address */
  26.                 
  27.         move.l    d1,-(sp)            /* save d1        */
  28.         
  29.         tst.b    CrsrCouple            /* make sure coupling is on before we do things */
  30.         beq        @Exit
  31.         
  32.         
  33.         move.w    MTemp.h,d0        /* Get Delta horizontal */
  34.         sub.w    RawMouse.h,d0
  35.         add.w    OFFSET(crsrTaskVars,Velh)(a0),d0    /* add to vel.h */
  36.         move.w    d0,OFFSET(crsrTaskVars,Velh)(a0)
  37.         add.w    OFFSET(crsrTaskVars,Prevh)(a0),d0    /* add vel to position */
  38.         move.w    d0,d1        /* save a floating position */
  39.         asr.w    #3,d0        /* truncate to an integer    */
  40.         move.w    d0,RawMouse.h    /* move the mouse there    */
  41.         
  42.         /*
  43.          * The next bit is a tad weird.  If the mouse hits the edge of
  44.          * the screen, the Velv &Velh variables need to be limited.
  45.          * The easiest way to check for boundries is when the cursor
  46.          * hasn't moved inspite of our attempts to move it.
  47.          */
  48.         move.w    Mouse.h,d0
  49.         cmp.w    OFFSET(crsrTaskVars,PrevInth)(a0),d0
  50.         beq.s    @1        /* we're not moving, don't update tickcounter  */
  51.         
  52.         move.l    Ticks,OFFSET(crsrTaskVars,LastTimeh)(a0)
  53.         move.w    d0,OFFSET(crsrTaskVars,PrevInth)(a0)
  54.         
  55.        @1
  56.         move.w    d1,OFFSET(crsrTaskVars,Prevh)(a0)    /* remember for next pass */
  57.         
  58.         /*
  59.          * Now really test to see if the cursor is moving.  If 9
  60.          * ticks have elapsed since last movement, assume we've hit the
  61.          * wall and therefore should clip the velocity and re-sync the
  62.          * position.
  63.          */
  64.         move.l    OFFSET(crsrTaskVars,LastTimeh)(a0),d0
  65.         sub.l    Ticks,d0
  66.         cmp.w    #-9,d0
  67.         bge.s    @3
  68.         
  69.         move.l    Ticks,OFFSET(crsrTaskVars,LastTimeh)(a0)
  70.         clr.w    OFFSET(crsrTaskVars,Velh)(a0)        /* zero vel    */
  71.         move.w    Mouse.h,d0
  72.         move.w    d0,OFFSET(crsrTaskVars,PrevInth)(a0) /* sync int pos */
  73.         asl.w    #3,d0
  74.         move.w    d0,OFFSET(crsrTaskVars,Prevh)(a0)  /* sync float pos */
  75.         
  76.        @3
  77.         /*
  78.          * now do the same thing for the vertical coordinates.
  79.          */
  80.         move.w    RawMouse.v,d0
  81.         sub.w    MTemp.v,d0
  82.         neg.w    d0
  83.         add.w    OFFSET(crsrTaskVars,Velv)(a0),d0
  84.         move.w    d0,OFFSET(crsrTaskVars,Velv)(a0)
  85.         add.w    OFFSET(crsrTaskVars,Prevv)(a0),d0
  86.         move.w    d0,d1
  87.         asr.w    #3,d0
  88.         move.w    d0,RawMouse.v
  89.         
  90.         move.w    Mouse.v,d0
  91.         cmp.w    OFFSET(crsrTaskVars,PrevIntv)(a0),d0
  92.         beq.s    @2
  93.         
  94.         move.l    Ticks,OFFSET(crsrTaskVars,LastTimev)(a0)
  95.         move.w    d0,OFFSET(crsrTaskVars,PrevIntv)(a0)
  96.         
  97.        @2
  98.         move.w    d1,OFFSET(crsrTaskVars,Prevv)(a0)    /* remember for next pass */
  99.         
  100.         move.l    OFFSET(crsrTaskVars,LastTimev)(a0),d0
  101.         sub.l    Ticks,d0
  102.         cmp.w    #-9,d0
  103.         bge.s    @4
  104.         
  105.         move.l    Ticks,OFFSET(crsrTaskVars,LastTimev)(a0)
  106.         clr.w    OFFSET(crsrTaskVars,Velv)(a0)        /* zero vel    */
  107.         move.w    Mouse.v,d0
  108.         move.w    d0,OFFSET(crsrTaskVars,PrevIntv)(a0) /* sync int pos */
  109.         asl.w    #3,d0
  110.         move.w    d0,OFFSET(crsrTaskVars,Prevv)(a0)  /* sync float pos */
  111.         
  112.        @4
  113.         
  114.         /*
  115.          * The setting of CrsrNew effects Obscuring the cursor.  If CrsrNew
  116.          * is always forced high, then the cursor will not dissapear while
  117.          * you're typeing.
  118.          */
  119.         move.l    RawMouse,d0        /* Get 'old'    */
  120.         cmp.l    MTemp,d0        /* Same as 'new'? */
  121.         beq.s    @Exit
  122.         move.l    d0,MTemp        /* Nope, move it */
  123.         move.b    #0xFF,CrsrNew
  124.         
  125.         /*
  126.          * Notice that MTemp=RawMouse.  This is done to avoid having the
  127.          * real jCrsrTask from extracting Delta info as I did and then
  128.          * scaling the results up.
  129.          */
  130.         
  131.        Exit:
  132.         move.l    (sp)+,d1
  133.         move.l    OFFSET(crsrTaskVars,OldCrsrTask)(a0),a0
  134.                                         /* get original routine */
  135.         jmp        (a0)            /* go there  */
  136.         }
  137.     }
  138.